package Stana;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import com.linuxense.javadbf.DBFException;
import com.linuxense.javadbf.DBFField;
import com.linuxense.javadbf.DBFReader;

public class ReadFile {
	     public ReadFile()
	     {
	      Object []rowObjects;
	      Object x1=null,y1 = null,y2=null,vq=null;
	     // Vector<Double> vec=new Vector<Double>();
	     
	    try {
	    	 
	      // create a DBFReader object
	      //
	      InputStream inputStream  = new FileInputStream("C:\\Users\\Poornendu Prakash Si\\Downloads\\LC_TRANS.DBF"); // take dbf file as program argument
	      DBFReader reader = new DBFReader( inputStream); 
	
	      // get the field count if you want for some reasons like the following
	      //
	      int numberOfFields = reader.getFieldCount();
	
	      // use this count to fetch all field information
	      // if required
	      //
	      
	      for( int i=0; i<numberOfFields; i++) {
	
	        DBFField field = reader.getField( i);
	
	        // do something with it if you want
	        // refer the JavaDoc API reference for more details
	        //
	        //System.out.println(field.getName());
	      }
	
	      // Now, lets us start reading the rows
	      //
	     
	      while( (rowObjects = reader.nextRecord()) != null) {
	
	        for( int i=0; i<rowObjects.length; i++)
	        {
	        
	          x1=rowObjects[1];
	          y1=rowObjects[5];
	          y2=rowObjects[6];
	         
	       } 
	       
	      }
	      
	     
	      inputStream.close();
	     
	    }
	    catch( DBFException e) {
	
	      System.out.println( e.getMessage());
	    }
	    catch( IOException e) {
	
	      System.out.println( e.getMessage());
	    }
	  //  addButton();
	  }
}

